layui.use(['form','layer'],function(){
	var form = layui.form,
		layer = parent.layer === undefined ? layui.layer : parent.layer,
		$ = layui.jquery;
	//video背景
	$(window).resize(function(){
		if($(".video-player").width() > $(window).width()){
			$(".video-player").css({"height":$(window).height(),"width":"auto","left":-($(".video-player").width()-$(window).width())/2});
		}else{
			$(".video-player").css({"width":$(window).width(),"height":"auto","left":-($(".video-player").width()-$(window).width())/2});
		}
	}).resize();
	
	//登录按钮事件
	form.on("submit(login)",function(data){
        // console.log(data.field); //当前容器的全部表单字段，名值对形式：{name: value}
        NProgress.start();
        $.ajax({
            url: "/login",
            type: "post",
            data:data.field,
            dataType: "text",
            success: function (data) {
                var obj =  JSON.parse(data);;
                if(obj){
                    if(obj.statusCode=='0')
                        window.location.href = "/";
                    else
                        layer.msg(obj.message, {icon: 5,title:"错误信息"});
                }else
                    layer.msg(data,{icon:5});
                NProgress.done();
            },
            error:function (data) {
                NProgress.done();
                layer.msg(data, {icon: 5});
            }
        });
		return false;
	});

    $(".code").click(function(){
        $("#imgCode").attr('src','../servlet/validateCodeServlet?'+new Date().getTime());
    });
})
